package murcielago.GUI;

import javax.microedition.lcdui.*;
import murcielago.main.Murcielago;
/**
 *
 * @author gato
 */
public class ScreenGui implements CommandListener{
    
    private Murcielago murcielago;
    protected Display display;
    protected Command exitCommand;
    protected Command activarCommand;
    protected Command configCommand;
    protected Command writerCommand;
    protected Command fileCommand;
    
    public ScreenGui(Murcielago murcielago){
        this.murcielago = murcielago;
        
        display = murcielago.getDisplay();
        
        exitCommand = new Command("Exit", Command.EXIT, 2);
        activarCommand = new Command("Activate", Command.OK, 1);
        configCommand = new Command("Config.", Command.SCREEN, 3);
        writerCommand = new Command("Write", Command.SCREEN, 4);
        fileCommand = new Command("Open File", Command.SCREEN, 5);
    }
    
    protected void cargarComponentes(Form screen){
        //CARGAR COMANDOS
        screen.addCommand(exitCommand);
        screen.addCommand(activarCommand);
        screen.addCommand(configCommand);
        screen.addCommand(writerCommand);
        screen.addCommand(fileCommand);
        //ESTABLECER LISTENER DE COMANDOS
        screen.setCommandListener(this);
    }
    
    public void commandAction(Command c, Displayable s) {
        // Salir
        if (c == activarCommand) {            
            //LLAMAR FUNCION TTS
        }else if(c == exitCommand){
            murcielago.destroyApp(false);
            murcielago.notifyDestroyed();
        }else if( c == writerCommand ){
            TextWriter text = new TextWriter(murcielago);
            //display.setCurrent(text.getScreen());
        }else if( c == fileCommand ){
            OpenFile open = new OpenFile(murcielago);
            display.setCurrent(open.getScreen());
        }
     }

}
